﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="landscapeConfig"
    targetNamespace="urn:landscape-config"
    elementFormDefault="qualified"
    xmlns="urn:landscape-config"
    xmlns:mstns="urn:landscape-config"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
  <xs:complexType name="lscCompilerNode">
    <xs:attribute name="assembly" type="xs:string" use="required"/>
    <xs:attribute name="type" type="xs:string" use="required"/>
  </xs:complexType>
  
  <xs:complexType name="lscPathSourceNode">
    <xs:sequence minOccurs="0" maxOccurs="unbounded">
      <xs:element name="add" type="lscPathPriorityNode"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="lscVirtualPathSourceNode">
    <xs:sequence minOccurs="0" maxOccurs="unbounded">
      <xs:element name="add" type="lscVirtualPathPriorityNode"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="lscExtensionsSourceNode">
    <xs:sequence minOccurs="0" maxOccurs="unbounded">
      <xs:element name="add" type="lscExtensionNode"/>
    </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="lscPathPriorityNode">
    <xs:attribute name="path" type="xs:string" use="required"/>
    <xs:attribute name="priority" type="xs:int" use="optional"/>
  </xs:complexType>

  <xs:simpleType name="aspNetVirtualPath">
    <xs:restriction base="xs:token">
      <xs:pattern value="^~/.*"/>
    </xs:restriction>
  </xs:simpleType>  

  <xs:complexType name="lscVirtualPathPriorityNode">
    <xs:attribute name="virtualpath" type="aspNetVirtualPath" use="required"/>
    <xs:attribute name="priority" type="xs:int" use="optional"/>
  </xs:complexType>

  <xs:complexType name="lscExtensionNode">
    <xs:attribute name="alias" type="xs:string" use="required"/>
    <xs:attribute name="assembly" type="xs:string" use="required"/>
    <xs:attribute name="type" type="xs:string" use="required"/>
  </xs:complexType>

  <xs:complexType name="lscRootNode">
    <xs:sequence minOccurs="0" maxOccurs="unbounded">
      <xs:element name="compiler" minOccurs="0" maxOccurs="1" type="lscCompilerNode"/>      
      <xs:element name="templates" minOccurs="0" maxOccurs="1" type="lscPathSourceNode">
        <xs:unique name="uniquePriorityForSourceOfTemplates">
          <xs:selector xpath="mstns:add"/>
          <xs:field xpath="@priority"/>
        </xs:unique>
      </xs:element>
      <xs:element name="widgets" minOccurs="0" maxOccurs="1" type="lscPathSourceNode">
        <xs:unique name="uniquePriorityForSourceOfWidgets">
          <xs:selector xpath="mstns:add"/>
          <xs:field xpath="@priority"/>
        </xs:unique>
      </xs:element>
      <xs:element name="includes" minOccurs="0" maxOccurs="1" type="lscPathSourceNode">
        <xs:unique name="uniquePriorityForSourceOfIncludes">
          <xs:selector xpath="mstns:add"/>
          <xs:field xpath="@priority"/>
        </xs:unique>
      </xs:element>
      <xs:element name="controls" minOccurs="0" maxOccurs="1" type="lscVirtualPathSourceNode">
        <xs:unique name="uniquePriorityForSourceOfControls">
          <xs:selector xpath="mstns:add"/>
          <xs:field xpath="@priority"/>
        </xs:unique>
      </xs:element>
      <xs:element name="extensions" minOccurs="0" maxOccurs="1" type="lscExtensionsSourceNode">
        <xs:unique name="uniqueAliasForXSLTExtensions">
          <xs:selector xpath="mstns:add"/>
          <xs:field xpath="@alias"/>
        </xs:unique>
        <xs:unique name="uniqueAssemblyFQDNForXSLTExtensions">
          <xs:selector xpath="mstns:add"/>
          <xs:field xpath="@assembly"/>
          <xs:field xpath="@type"/>
        </xs:unique>
      </xs:element>
    </xs:sequence> 
  </xs:complexType>
  <xs:element name="landscape" type="lscRootNode"/>
</xs:schema>
